/*
 * RenderObject.h
 *
 *  Created on: 11 Jan 2013
 *      Author: jonsl
 */

#ifndef RENDEROBJECT_H_
#define RENDEROBJECT_H_

#include "Core.h"
#include "Transform2.h"
#include "RenderTypes.h"
#include "RenderObject.h"
#include "RenderProgram.h"

namespace p2
{

class RenderObject : public RealTimeType
{
DECLARE_RTT(RenderObject, RealTimeType);

public:
	typedef std::list<RenderObject, boost::fast_pool_allocator<RenderObject> > List;

public:
    inline RenderObject()
    :   _type(NUM_PROGRAMS),
		_mode((GLenum)~0),
        _verticesId(0),
        _texId(),
        _texWidth(0),
        _texHeight(0),
        _numCoords(0),
        _transform(),   // set identity
        _userData(NULL)
    {
    }
    virtual ~RenderObject();

    inline void setVC(GLenum mode, GLuint verticesId);
    inline void setVT(GLenum mode, GLuint verticesId, GLuint texId, GLsizei texWidth, GLsizei texHeight);
    inline void setVTC(GLenum mode, GLuint verticesId, GLuint texId, GLsizei texWidth, GLsizei texHeight);

    /*
     * access
     */
	inline GLenum getMode() const;
	inline void setMode(GLenum mode);
	inline GLint getNumCoords() const;
	inline void setNumCoords(GLint numCoords);
	inline GLsizei getTexHeight() const;
	inline void setTexHeight(GLsizei texHeight);
	inline GLuint getTexId() const;
	inline void setTexId(GLuint texId);
	inline GLsizei getTexWidth() const;
	inline void setTexWidth(GLsizei texWidth);
	inline const Transform2<real>& getTransform() const;
	inline void setTransform(const Transform2<real>& transform);
	inline uint32 getType() const;
	inline void setType(uint32 type);
	inline void* getUserData() const;
	inline void setUserData(void* userData);
	inline GLuint getVerticesId() const;
	inline void setVerticesId(GLuint verticesId);

private:
	uint32 _type;
    GLenum _mode;
    GLuint _verticesId;
    GLuint _texId;
    GLsizei _texWidth;
    GLsizei _texHeight;
    GLint _numCoords;
    Transform2<real> _transform;
    void* _userData;
};

inline void RenderObject::setVC(GLenum mode, GLuint verticesId)
{
	_type = PROGRAM_VC;
    _mode = mode;
    _verticesId = verticesId;
}

inline void RenderObject::setVT(GLenum mode, GLuint verticesId, GLuint texId, GLsizei texWidth, GLsizei texHeight)
{
	_type = PROGRAM_VT;
    _mode = mode;
    _verticesId = verticesId;
    _texId = texId;
    _texWidth = texWidth;
    _texHeight = texHeight;
}

inline void RenderObject::setVTC(GLenum mode, GLuint verticesId, GLuint texId, GLsizei texWidth, GLsizei texHeight)
{
	_type = PROGRAM_VTC;
    _mode = mode;
    _verticesId = verticesId;
    _texId = texId;
    _texWidth = texWidth;
    _texHeight = texHeight;
}

/*
 * access
 */
inline GLenum RenderObject::getMode() const
{
	return _mode;
}

inline void RenderObject::setMode(GLenum mode)
{
	_mode = mode;
}

inline GLint RenderObject::getNumCoords() const
{
	return _numCoords;
}

inline void RenderObject::setNumCoords(GLint numCoords)
{
	_numCoords = numCoords;
}

inline GLsizei RenderObject::getTexHeight() const
{
	return _texHeight;
}

inline void RenderObject::setTexHeight(GLsizei texHeight)
{
	_texHeight = texHeight;
}

inline GLuint RenderObject::getTexId() const
{
	return _texId;
}

inline void RenderObject::setTexId(GLuint texId)
{
	_texId = texId;
}

inline GLsizei RenderObject::getTexWidth() const
{
	return _texWidth;
}

inline void RenderObject::setTexWidth(GLsizei texWidth)
{
	_texWidth = texWidth;
}

inline const Transform2<real>& RenderObject::getTransform() const
{
	return _transform;
}

inline void RenderObject::setTransform(const Transform2<real>& transform)
{
	_transform = transform;
}

inline uint32 RenderObject::getType() const
{
	return _type;
}

inline void RenderObject::setType(uint32 type)
{
	_type = type;
}

inline void* RenderObject::getUserData() const
{
	return _userData;
}

inline void RenderObject::setUserData(void* userData)
{
	_userData = userData;
}

inline GLuint RenderObject::getVerticesId() const
{
	return _verticesId;
}

inline void RenderObject::setVerticesId(GLuint verticesId)
{
	_verticesId = verticesId;
}

} /* namespace p2 */

#endif /* RENDEROBJECT_H_ */
